package com.sofwin.configer;

import com.sofwin.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @packageName: com.sofwin.configer
 * @user: andyliu
 * @date: 2022/12/16 10:30
 * @email 115176513@qq.com
 * @description: TODO
 */
@Configuration
@ComponentScan("com.sofwin")
@EnableWebMvc
public class MvcConfiger implements WebMvcConfigurer {
//    @Autowired
//    private LoginInterceptor loginInterceptor;
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        registry.jsp().prefix("/WEB-INF/").suffix(".jsp");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//       registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("/login");
    }
    /**
     * 静态资源的配置 == mvc:resources
     * @param registry
     */
//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/static/**").addResourceLocations("/static/");
//    }

    /**
     * mvc-servlet-handler
     * @param configurer
     */
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
}
